#include "fileimportplugin.h"
#include "fileimportmodule.h"
#include <QtPlugin>
#include <QFileDialog>
#include <QUrl>

Q_EXPORT_PLUGIN2(fileimportplugin, FileImportPlugin)

void FileImportPlugin::setup(PioCore * core)
{
    m_core = core;
    m_import = new FileImportModule(m_core);
    core->registerImportModule(m_import);
    core->toolbar()->addAction(tr("Import directory..."), this, SLOT(import()));
}

QStringList FileImportPlugin::licenseInfo()
{
    return QStringList();
}

void FileImportPlugin::import()
{
    QString path = QFileDialog::getExistingDirectory(m_core->mainwindow());
    if(path.isEmpty())
        return;

    m_core->import(QUrl::fromLocalFile(path));
}
